package leetcode.weekly.week331;

import java.util.PriorityQueue;

//Solution1Test
public class Solution1 {

	public long pickGifts(int[] gifts, int k) {
		PriorityQueue<Integer> queue = new PriorityQueue<>((a, b) -> b - a);
		for (int num : gifts) {
			queue.add(num);
		}
		while (k > 0) {
			int num = queue.poll();
			queue.add(Math.max((int) Math.sqrt(num), 1));
			k--;
		}
		long ans = 0;
		while (!queue.isEmpty()) {
			ans += queue.poll();
		}
		return ans;
	}

	public static void main(String[] args) {
		System.out.println();
	}
}
